//
//  LLChatManager+MessageExt.m
//  LLWeChat
//
//  Created by GYJZH on 9/4/16.
//  Copyright © 2016 GYJZH. All rights reserved.
//

#import "LLChatManager+MessageExt.h"
#import "LLConfig.h"

@implementation LLChatManager (MessageExt)

- (NSMutableDictionary *)encodeLocationMessageExt:(double)latitude longitude:(double)longitude address:(NSString *)address name:(NSString *)name zoomLevel:(CGFloat)zoomLevel defaultSnapshot:(BOOL)defaultSnapshot {
    NSDictionary *messageExt = @{@"latitude":@(latitude).stringValue,
                                 @"longitude": @(longitude).stringValue,
                                 @"address": address,
                                 @"name":name,
                                 @"scale": @([UIScreen mainScreen].scale).stringValue,
                                 @"zoomLevel":@(zoomLevel).stringValue,
                                 @"defaultSnapshot":@(defaultSnapshot),
                                 MESSAGE_EXT_TYPE_KEY: MESSAGE_EXT_LOCATION_KEY
                                 };
    
    return [messageExt mutableCopy];
}


- (void)decodeMessageExtForLocationType:(LLMessageModel *)messageModel {
    NSDictionary *messageExt = messageModel.ext;
    
    CLLocationCoordinate2D coordinate2D;
    coordinate2D.latitude = [messageExt[@"latitude"] doubleValue];
    coordinate2D.longitude = [messageExt[@"longitude"] doubleValue];
    messageModel.coordinate2D = coordinate2D;
    
    messageModel.snapshotScale = [messageExt[@"scale"] doubleValue];
    messageModel.zoomLevel = [messageExt[@"zoomLevel"] doubleValue];
    messageModel.address = messageExt[@"address"];
    messageModel.locationName = messageExt[@"name"];
    messageModel.defaultSnapshot = [messageExt[@"defaultSnapshot"] boolValue];
}
- (NSString *)gifPathNameForGIFMessageModel:(LLMessageModel *)model {
    return model.ext[@"codeId"];
}


@end
